import allure
from faker import Faker

from page_object.roncoo_login import RoncooLogin
from page_element.el_settlement import *
import logging

from utils.mysql_util import PyMySql
from utils.timer import sleep
import allure
from faker import Faker

from page_base.page_base import Base
# from page_element.el_A3mall import *
from page_element.roncoo_sett import *
from page_element.el_user import *
from page_object.roncoo_login import RoncooLogin
from utils.mysql_util import PyMySql
from utils.timer import sleep
import logging

class Recnoo_settlement(RoncooLogin):
    """首页搜索商品后退出登录"""

    def recnoo_yhsettlement_use(self):
        self.db = PyMySql()
        self.fk = Faker(locale='zh_CN')
        # 添加用户

        name = self.fk.name()
        with allure.step(f"点击用户管理"):
            self.click(recnoo.recnoo_yggl)
            sleep(2)
        with allure.step(f"点击用户信息"):
            self.click(recnoo.recnoo_yyxx)
        with allure.step(f"点击添加按钮"):
            self.click(recnoo.recnoo_tjan)
        with allure.step(f"输入用户名称"):
            self.send_keys(recnoo.recnoo_yhmc, name)
            sleep(2)
        with allure.step(f"输入手机号"):
            self.send_keys(recnoo.recnoo_sjh, '18451121531')
            sleep(2)
        with allure.step(f"输入登录密码"):
            self.send_keys(recnoo.recnoo_dlmm, 'dlmm')
            sleep(2)
        with allure.step(f"点击提交按钮"):
            self.click(recnoo.recnoo_tijan)
            sleep(2)
        # 前置条件：已登录
        self.roncoo_login()
        with allure.step(f"点击结算管理"):
            self.click(recnoo.recnoo_jsgl)
        with allure.step(f"点击结算记录管理"):
            self.click(recnoo.recnoo_jsjl)
        with allure.step(f"点击发起结算按钮"):
            self.click(recnoo.recnoo_fqjsbtn)
        with allure.step(f"点击搜索图标"):
            self.click(recnoo.recnoo_sstb)
        with allure.step(f"选择用户名"):
            self.click(recnoo.recnoo_xz)
        with allure.step(f"点击获取可结算余额"):
            self.click(recnoo.recnoo_hqkjsye)
        with allure.step(f"输入结算余额"):
            self.send_keys(recnoo.recnoo_jsye, '100')
        with allure.step(f"点击提交按钮"):
            self.click(recnoo.recnoo_fqjsbtn)
        with allure.step(f"点击审核"):
            self.click(recnoo.recnoo_sh)
        with allure.step(f"输入审核备注"):
            self.send_keys(recnoo.recnoo_shbz, '通过')
        with allure.step(f"点击提交按钮"):
            self.click(recnoo.recnoo_shbtn)
        with allure.step(f"点击打款"):
            self.click(recnoo.recnoo_dk)
        with allure.step(f"输入打款备注"):
            self.send_keys(recnoo.recnoo_dkbz, '通过')
        with allure.step(f"点击提交按钮"):
            self.click(recnoo.recnoo_dkbtn)
            sleep(2)
        with allure.step(f"断言"):
            dy = self.text(recnoo.recnoo_dy)
            assert '打款成功' == dy
